home *** CD-ROM | disk | FTP | other *** search
- Path: in1.uu.net!demos!usenet
- From: Alexey Ruzin <00alex@dbs.demos.su>
- Newsgroups: comp.lang.c++
- Subject: Re: Circular Usage (forward declaration?)
- Date: Wed, 17 Apr 1996 16:33:08 +0400
- Organization: Demos Online Service
- Message-ID: <3174E504.20D9@dbs.demos.su>
- References: <MRW.96Apr16184800@tobago.siemens.ch>
- <ltu3ykovzc.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- <31747631.5970@datalytics.com> <MRW.96Apr17104121@tobago.siemens.ch>
- NNTP-Posting-Host: 00alex@dbs.demos.su
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
-
- Waeckerlin Marc wrote:
- >
- > Hi
- >
- > Thank you for the answers.
- >
- > I know this way, but it does not work in my case, since the members "x"
- > absolutely must be no pointers.
- > Speaking more exactly, they are pointers, but they are smart pointers.
- > In another example, you could get somnething like this, where "CPointer"
- > is a smart pointer:
- >
- > class CCompany
- > {
- > protected:
- >
- > CPointer<CEmployee> m_emp;
- >
- > public:
- >
- > set(CEmployee &p_emp)
- > {
- > m_emp = &p_emp;
- > }
- > };
- >
- > class CEmployee
- > {
- > protected:
- >
- > CPointer<CCompany> m_comp;
- >
- > public:
- >
- > set(CCompany &p_comp)
- > {
- > m_comp = &p_comp;
- > }
- > };
- >
- > Best Regards
- > Marc
- >
-
- If you really need to have so hard link between two objects
- may be you may bind both objects in one?
-
- You can use derived classes to define your new class:
-
- class CEmployee_Company: public CEmployee, public CCompany
- {
- ...
- };
-
- I don't know what do you really need, it's hard to advice...
-